#include "player.hh"

Player::Player ()
{}

Player::~Player ()
{
  std::list<Building*>::iterator it1;

  for (it1 = b_list_.begin (); it1 != b_list_.end (); ++it1)
    delete *it1;
  b_list_.clear ();

  std::list<Unit*>::iterator it2;

  for (it2 = u_list_.begin (); it2 != u_list_.end (); ++it2)
    delete *it2;
  u_list_.clear ();
}

bool
Player::del_building (Building* b)
{
  std::list<Building*>::iterator it = find (b_list_.begin (), b_list_.end (), b);

  if (it != b_list_.end ())
    {
      delete *it;
      b_list_.erase (it);
      return true;
    }

  return false;
}

bool
Player::del_unit (Unit* u)
{
  std::list<Unit*>::iterator it = find (u_list_.begin (), u_list_.end (), u);

  if (it != u_list_.end ())
    {
      delete *it;
      u_list_.erase (it);
      return true;
    }

  return false;
}
